<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>~/Documents/git/gitee/it/书籍/从Paxos到Zookeeper.md.html</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim8.1_v2">
<meta name="syntax" content="markdown">
<meta name="settings" content="number_lines,use_css,pre_wrap,no_foldcolumn,expand_tabs,line_ids,prevent_copy=,use_input_for_pc=fallback">
<meta name="colorscheme" content="catppuccin">
<style>
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #d9e0ee; background-color: #1e1e2e; }
body { font-family: monospace; color: #d9e0ee; background-color: #1e1e2e; }
* { font-size: 1em; }
.markdownH2 { color: #ddb6f2; }
.markdownH3 { color: #abe9b3; }
.markdownH1 { color: #c9cbff; }
.LineNr { color: #575268; }
.markdownH6 { color: #b5e8e0; }
.Statement { color: #ddb6f2; }
.markdownHeadingDelimiter { color: #f8bd96; font-weight: bold; }
.markdownH4 { color: #fae3b0; }
.markdownH5 { color: #f5c2e7; }
-->
</style>

<script>
<!--

/* function to open any folds containing a jumped-to line before jumping to it */
function JumpToLine()
{
  var lineNum;
  lineNum = window.location.hash;
  lineNum = lineNum.substr(1); /* strip off '#' */

  if (lineNum.indexOf('L') == -1) {
    lineNum = 'L'+lineNum;
  }
  var lineElem = document.getElementById(lineNum);
  /* Always jump to new location even if the line was hidden inside a fold, or
   * we corrected the raw number to a line ID.
   */
  if (lineElem) {
    lineElem.scrollIntoView(true);
  }
  return true;
}
if ('onhashchange' in window) {
  window.onhashchange = JumpToLine;
}

-->
</script>
</head>
<body onload='JumpToLine();'>
<pre id='vimCodeElement'>
<span id="L1" class="LineNr"> 1 </span><span class="markdownHeadingDelimiter">##</span><span class="markdownH2"> 分布式架构</span>
<span id="L2" class="LineNr"> 2 </span><span class="markdownHeadingDelimiter">###</span><span class="markdownH3"> 集中式</span>
<span id="L3" class="LineNr"> 3 </span>
<span id="L4" class="LineNr"> 4 </span>所谓的集中式系统就是指由一台或多台主计算机组成中心节点，数据集中存储于这个中心节点中，并且整个系统的所有业务单元都集中部署在这个中心节点上，系统的所有功能均由其集中处理。也就是说，在集中式系统中，每个终端或客户端机器仅仅负责数据的录入和输出，而数据的存储与控制处理完全交由主机来完成。
<span id="L5" class="LineNr"> 5 </span>
<span id="L6" class="LineNr"> 6 </span>集中式系统最大的特点就是部署结构简单。由于集中式系统往往基于底层性能卓越的大型主机，因此无须考虑如何对服务进行多个节点的部署，也就不用考虑多个节点之间的分布式协作问题。
<span id="L7" class="LineNr"> 7 </span>
<span id="L8" class="LineNr"> 8 </span><span class="markdownHeadingDelimiter">###</span><span class="markdownH3"> 分布式</span>
<span id="L9" class="LineNr"> 9 </span>分布式系统是一个硬件或软件组件分布在不同的网络计算机上，彼此之间仅仅通过消息传递进行通信和协调的系统。
<span id="L10" class="LineNr">10 </span>
<span id="L11" class="LineNr">11 </span>上面这个简单的定义涵盖了几乎所有有效地部署了网络化计算机的系统。严格地讲，同一个分布式系统中的计算机在空间部署上是可以随意分布的，这些计算机可能被放在不同的机柜上，也可能在不同的机房中，甚至分布在不同的城市。无论如何，一个标准的分布式系统在没有任何特定业务逻辑约束的情况下，都会有如下几个特征。
<span id="L12" class="LineNr">12 </span>
<span id="L13" class="LineNr">13 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 特征</span>
<span id="L14" class="LineNr">14 </span>分布性
<span id="L15" class="LineNr">15 </span>
<span id="L16" class="LineNr">16 </span>分布式系统中的多台计算机都会在空间上随意分布，同时，机器的分布情况也会随时变动。
<span id="L17" class="LineNr">17 </span>
<span id="L18" class="LineNr">18 </span>对等性
<span id="L19" class="LineNr">19 </span>
<span id="L20" class="LineNr">20 </span>并发性
<span id="L21" class="LineNr">21 </span>
<span id="L22" class="LineNr">22 </span>在“问题的提出”部分，我们已经提到过与“更新的并发性”相关的内容。在一个计算机网络中，程序运行过程中的并发性操作是非常常见的行为，例如同一个分布式系统中的多个节点，可能会并发地操作一些共享的资源，诸如数据库或分布式存储等，如何准确并高效地协调分布式并发操作也成为了分布式系统架构与设计中最大的挑战之一。缺乏全局时钟在上面的讲解中，我们已经了解到，一个典型的分布式系统是由一系列在空间上随意分布的多个进程组成的，具有明显的分布性，这些进程之间通过交换消息来进行相互通信。因此，在分布式系统中，很难定义两个事件究竟谁先谁后，原因就是因为分布式系统缺乏一个全局的时钟序列控制。关于分布式系统的时钟和事件顺序，在 Leslie Lamport[2]的经典论文 Time，Clocks，and the Ordering of Events in a Distributed System[3]中已经做了非常深刻的讲解。
<span id="L23" class="LineNr">23 </span>
<span id="L24" class="LineNr">24 </span>缺乏全局时钟
<span id="L25" class="LineNr">25 </span>
<span id="L26" class="LineNr">26 </span>故障总会发生
<span id="L27" class="LineNr">27 </span>
<span id="L28" class="LineNr">28 </span><span class="markdownHeadingDelimiter">###</span><span class="markdownH3"> 问题</span>
<span id="L29" class="LineNr">29 </span>
<span id="L30" class="LineNr">30 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 通信异常</span>
<span id="L31" class="LineNr">31 </span>
<span id="L32" class="LineNr">32 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 网络分区</span>
<span id="L33" class="LineNr">33 </span>
<span id="L34" class="LineNr">34 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 三态</span>
<span id="L35" class="LineNr">35 </span>
<span id="L36" class="LineNr">36 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 节点故障</span>
<span id="L37" class="LineNr">37 </span>
<span id="L38" class="LineNr">38 </span><span class="markdownHeadingDelimiter">###</span><span class="markdownH3"> ACID</span>
<span id="L39" class="LineNr">39 </span>
<span id="L40" class="LineNr">40 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 原子性</span>
<span id="L41" class="LineNr">41 </span>
<span id="L42" class="LineNr">42 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 隔离性</span>
<span id="L43" class="LineNr">43 </span>
<span id="L44" class="LineNr">44 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 一致性</span>
<span id="L45" class="LineNr">45 </span>
<span id="L46" class="LineNr">46 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> 持久性</span>
<span id="L47" class="LineNr">47 </span>
<span id="L48" class="LineNr">48 </span>
<span id="L49" class="LineNr">49 </span><span class="markdownHeadingDelimiter">###</span><span class="markdownH3"> 分布式事务</span>
<span id="L50" class="LineNr">50 </span>
<span id="L51" class="LineNr">51 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> CAP理论</span>
<span id="L52" class="LineNr">52 </span>
<span id="L53" class="LineNr">53 </span><span class="markdownHeadingDelimiter">#####</span><span class="markdownH5"> 一致性</span>
<span id="L54" class="LineNr">54 </span>
<span id="L55" class="LineNr">55 </span><span class="markdownHeadingDelimiter">#####</span><span class="markdownH5"> 可用性</span>
<span id="L56" class="LineNr">56 </span>
<span id="L57" class="LineNr">57 </span><span class="markdownHeadingDelimiter">#####</span><span class="markdownH5"> 分区容错性</span>
<span id="L58" class="LineNr">58 </span>
<span id="L59" class="LineNr">59 </span><span class="markdownHeadingDelimiter">####</span><span class="markdownH4"> BASE理论</span>
<span id="L60" class="LineNr">60 </span>
<span id="L61" class="LineNr">61 </span><span class="markdownHeadingDelimiter">#####</span><span class="markdownH5"> 基本可用</span>
<span id="L62" class="LineNr">62 </span>
<span id="L63" class="LineNr">63 </span><span class="markdownHeadingDelimiter">#####</span><span class="markdownH5"> 弱状态</span>
<span id="L64" class="LineNr">64 </span>
<span id="L65" class="LineNr">65 </span>
<span id="L66" class="LineNr">66 </span>
<span id="L67" class="LineNr">67 </span><span class="markdownHeadingDelimiter">#####</span><span class="markdownH5"> 基本可用</span>
<span id="L68" class="LineNr">68 </span><span class="Statement">*</span> 响应时间上的损失
<span id="L69" class="LineNr">69 </span><span class="Statement">*</span> 功能上的损失
<span id="L70" class="LineNr">70 </span><span class="markdownHeadingDelimiter">#####</span><span class="markdownH5"> 弱状态</span>
<span id="L71" class="LineNr">71 </span>
<span id="L72" class="LineNr">72 </span><span class="markdownHeadingDelimiter">#####</span><span class="markdownH5"> 最终一致性</span>
<span id="L73" class="LineNr">73 </span>
<span id="L74" class="LineNr">74 </span><span class="markdownHeadingDelimiter">######</span><span class="markdownH6"> 因果一致性</span>
<span id="L75" class="LineNr">75 </span>
<span id="L76" class="LineNr">76 </span><span class="markdownHeadingDelimiter">######</span><span class="markdownH6"> 读已之所写</span>
<span id="L77" class="LineNr">77 </span><span class="markdownHeadingDelimiter">######</span><span class="markdownH6"> 会话一致性</span>
<span id="L78" class="LineNr">78 </span><span class="markdownHeadingDelimiter">######</span><span class="markdownH6"> 单调读一致性</span>
<span id="L79" class="LineNr">79 </span><span class="markdownHeadingDelimiter">######</span><span class="markdownH6"> 单调写一致性（Monotonic write consistency）</span>
<span id="L80" class="LineNr">80 </span>
<span id="L81" class="LineNr">81 </span>单调写一致性是指，一个系统需要能够保证来自同一个进程的写操作被顺序地执行。
<span id="L82" class="LineNr">82 </span>
<span id="L83" class="LineNr">83 </span><span class="markdownHeadingDelimiter">#</span><span class="markdownH1"> 一致性协议</span>
<span id="L84" class="LineNr">84 </span>
<span id="L85" class="LineNr">85 </span><span class="markdownHeadingDelimiter">###</span><span class="markdownH3"> 2PC</span>
<span id="L86" class="LineNr">86 </span>
<span id="L87" class="LineNr">87 </span><span class="markdownHeadingDelimiter">###</span><span class="markdownH3"> 3PC</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->
